package com.huqu.daoimpl;

import java.sql.Types;
import java.util.ArrayList;
import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Repository;

import com.huqu.basedao.QbDaoSupport;
import com.huqu.basedao.QbEntityMapper;
import com.huqu.basedao.QbSqlParam;
import com.huqu.dao.N500Dao;
import com.huqu.entities.N500;
import com.huqu.utils.ApplicationConstant;
import com.huqu.utils.SqlNames;

/**
 * @author CONGQUYNH
 */
@Repository(value = ApplicationConstant.REPOSITORY_NAME_N500)
@Scope("prototype")
public class N500DaoImpl extends QbDaoSupport implements N500Dao {

	/* (non-Javadoc)
	 * @see com.huqu.dao.N500Dao#InsertTabN500(int, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, int, int, int)
	 */
	@Override
	public int InsertTabN500(int nIDVIDEO, int nIDMUC, String vTENVIDEO_VI,
			String vTENVIDEO_EN, String vTOMTAT_VI, String vTOMTAT_EN,
			String vKEYLINK, String vNGUON, String vHINHANH, int nNGUOITAO,
			int nDAXOA, int nKIEMDUYET) {

		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.INTEGER, nIDVIDEO));
		listParams.add(new QbSqlParam(Types.INTEGER, nIDMUC));
		listParams.add(new QbSqlParam(Types.CHAR,vTENVIDEO_VI ));
		listParams.add(new QbSqlParam(Types.CHAR, vTENVIDEO_EN));
		listParams.add(new QbSqlParam(Types.CHAR, vTOMTAT_VI));
		listParams.add(new QbSqlParam(Types.CHAR, vTOMTAT_EN));
		listParams.add(new QbSqlParam(Types.CHAR, vKEYLINK));
		listParams.add(new QbSqlParam(Types.CHAR, vNGUON));
		listParams.add(new QbSqlParam(Types.CHAR, vHINHANH));
		listParams.add(new QbSqlParam(Types.INTEGER, nNGUOITAO));
		listParams.add(new QbSqlParam(Types.INTEGER, nDAXOA));
		listParams.add(new QbSqlParam(Types.INTEGER, nKIEMDUYET));
		setQueenBListSqlParams(listParams);
		// set fuction
		setQbFunction(true);
		setQbFunctionReturnType(Types.INTEGER);
		setQueenBSqlName(SqlNames.INSERTTABN500);
		executeQueenBQuery();
		int re = Integer.parseInt(getObjectReturnFunction().toString());
		return re;
	}

	/* (non-Javadoc)
	 * @see com.huqu.dao.N500Dao#ListOfTabN500(int, int, int, int, int, java.lang.String)
	 */
	@Override
	public List<N500> ListOfTabN500(int nIDMUC, int nOFFSET, int nLIMIT,
			int nSORT, int nGETNUMROW, String vLANG) {
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.INTEGER, nIDMUC));
		listParams.add(new QbSqlParam(Types.INTEGER, nOFFSET));
		listParams.add(new QbSqlParam(Types.INTEGER, nLIMIT));
		listParams.add(new QbSqlParam(Types.INTEGER, nSORT));
		listParams.add(new QbSqlParam(Types.INTEGER, nGETNUMROW));
		listParams.add(new QbSqlParam(Types.CHAR, vLANG));
		setQueenBListSqlParams(listParams);
		// set sql name
		setQueenBSqlName(SqlNames.LISTOFTABN500);
		// set row mapper
		setQueenBEntityMapper(new QbEntityMapper(N500.class));
		executeQueenBQuery();
		List<N500> listN500 = (List<N500>) getListReturn();
		return listN500;
	}

	/* (non-Javadoc)
	 * @see com.huqu.dao.N500Dao#ListOfTabN500INFO(java.lang.String, java.lang.String)
	 */
	@Override
	public List<N500> ListOfTabN500INFO(String vMD5VIDEO, String vLang) {
		List<QbSqlParam> listParams = new ArrayList<QbSqlParam>();
		listParams.add(new QbSqlParam(Types.CHAR, vMD5VIDEO));
		listParams.add(new QbSqlParam(Types.CHAR, vLang));
		setQueenBListSqlParams(listParams);
		// set sql name
		setQueenBSqlName(SqlNames.LISTOFTABN500INFO);
		// set row mapper
		setQueenBEntityMapper(new QbEntityMapper(N500.class));
		executeQueenBQuery();
		List<N500> listN500 = (List<N500>) getListReturn();
		return listN500;
	}

}
